package com.sheliduan.itlearning.common.config;

import com.sheliduan.itlearning.common.controller.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author: 断舍离
 * @date: 2025/2/3 10:42
 * @description: 拦截器配置类
 **/
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    /*
    * 拦截所有请求路径, 并添加自己的自定义拦截器JwtInterceptor
    * 需要放行的请求(比如登录/注册), 添加@AuthAccess注解即可
    * */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**");
        super.addInterceptors(registry);
    }

}
